#include <iostream>
#include "ShapeFactory.h"
#include "ButtonFactory.h"
#include "AbsFactory.h"

using namespace std;

int main(int argc, char const *argv[])
{
    // 简单工厂模式
    std::unique_ptr<Shape> obj1 = ShapeFactory::createShape(ShapeFactory::Type::CIRCLE);
    std::unique_ptr<Shape> obj2 = ShapeFactory::createShape(ShapeFactory::Type::RECTANGLE);
    obj1->draw();
    obj2->draw();

    // 工厂方法模式
    unique_ptr<ButtonFactory> bf;
#ifdef _WIN32
    bf = std::make_unique<WindowsButtonFactory>();
#else
    bf = std::make_unique<MacButtonFactory>();
#endif
    unique_ptr<Button> btn = bf->createButton();
    btn->btn_click(); // 可以再次封装，通过factory来调用btn_click

    // 抽象工厂模式
    unique_ptr<AbsFactory> absF;
#ifdef _WIN32
    absF = std::make_unique<WinFactory>();
#else
    absF = std::make_unique<MacFactory>();
#endif
    App app(std::move(absF));
    app.show();


    return 0;
}
